<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.ort">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <link th:href="@{/layui/css/layui.css}" rel="stylesheet" />
<body>
<div class="layui-panel" style="padding: 8px;">
    <table id="goodsTable" lay-filter="goodsTable"></table>
    <div id="tool" style="display: none">
        <a class="layui-btn" lay-event="look" id="look">查看详情
            <i class="layui-icon layui-icon-log"></i>
        </a>
    </div>
</div>
    <script id="photo" type="text/html">
        {{# if(d.photos[0]!=0){}}
        <img  src="/file/fc/showImg/{{d.photos[0]}}" style="width: 30px;height: 60px;">
        {{#}}}
    </script>
    <script>
        var $;
        layui.config({
            base:'../../../js/'
        })

        layui.use(['form','upload','jquery','dropdown','layedit','table','element','tree'],function() {
            var upload = layui.upload, dropdown = layui.dropdown, table = layui.table, form = layui.form,
                tree = layui.tree;
            elem = layui.element;
            $ = layui.jquery;
            table.render({
                elem:'#goodsTable',
                height:'full-60',
                url:'/goods/gc/find',
                cols:[
                    [
                        {fixed:'left',type:"numbers",title:'编号',width:50},
                        {field:"name",title: "商品名称"},
                        {field:"number",title: "商品编号"},
                        {field:"marketPrice",title: "市场价格"},
                        {field:"photo",title: "商品图片",templet:'#photo'},
                        {field:"inventory",title: "库存商品数量",templet:function (obj){
                            return obj.inventorys[0].num;
                            }},
                        {title: "商品价格",templet:function (obj){
                                return obj.inventorys[0].price;
                            }},
                        {field:"introduction",title: "商品简介"},
                        {fixed:"right",title: "操作",toolbar:'#tool'},
                    ]

                ]


            })
          table.on('tool(goodsTable)',function (obj){
              console.log(obj)
              var event = obj.event;
              if (event=="look"){
                  layer.open({
                      type:2,
                      content:'/page/look?id='+obj.data.id,
                      area:['800px','800px'],
                      btn:['确定保存','取消'],
                      btn1:function (index,o){
                          o.find('iframe')[0].contentWindow.submitBtn();
                          return false;
                      }
                  })

              }
          })

        })
    </script>
</body>
</html>